#include "Stdafx.h"
#include "OID.h"

using namespace SNMP;

OID::OID(void){}

OID::OID(String^ oid)
{
	array<String^>^ strTemp = oid->Split('.');
	this->m_uintSourceOID = gcnew array<UInt32>(strTemp->Length);
	UInt32 intTemp = 0;
	for(int i = 0; i < strTemp->Length; i++)
	{
		if(UINT32::TryParse(strTemp[i], intTemp))
		{
			this->m_uintSourceOID[i] = intTemp;
		}
		else
		{
			throw gcnew SNMPException("");
		}
	}
}

String^ OID::ToString(void)
{
	System::Text::StringBuilder^ sbTemp = gcnew System::Text::StringBuilder();
	for each (UINT32 var in this->m_uintSourceOID)
	{
		sbTemp->Append(var.ToString() + ".");
	}

	sbTemp->Remove(sbTemp->Length-1, 1);
	return sbTemp->ToString();
}